<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        /**
         * 消息转发规则
         */
        Schema::create('wxcallback_rules', function (Blueprint $table) {
            $table->id();
            $table->string('name', 64)->nullable(false)->default('');
            $table->string('infotype', 64)->nullable(false)->default('');
            $table->string('msgtype', 64)->nullable(false)->default('');
            $table->string('event', 64)->nullable(false)->default('');
            $table->integer('type')->nullable(false)->default(0);
            $table->integer('open')->nullable(false)->default(0);
            $table->text('info')->nullable(false);
            $table->timestamp('create_at')->default(DB::raw('CURRENT_TIMESTAMP'));
            $table->timestamp('update_at')->default(DB::raw('CURRENT_TIMESTAMP'))->useCurrentOnUpdate();
            $table->unique(['infotype', 'msgtype', 'event']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('wxcallback_rules');
    }
};
